feat(tui): Phase 8 多模态接入(图片/文件)+ Phase 9 会话切换(/session#308
Conversation
# Conflicts: # internal/runtime/errors.go
| a.state.CurrentTool = "" | ||
|
|
||
| if a.hasImageAttachments() { | ||
| a.appendActivity("multimodal", "Sending message with images", fmt.Sprintf("%d image(s) attached", len(a.pendingImageAttachments)), false) |
There was a problem hiding this comment.
The UI reports "Sending message with images", but this send path still proceeds with text-only runtime input. I don’t see image attachment payload being passed to runtime/provider from here, so attached images appear to be dropped despite the activity message.
|
|
||
| func SaveImageToTempFile(data []byte, prefix string) (string, error) { | ||
| tmpDir := os.TempDir() | ||
| tmpFile := tmpDir + "/" + prefix + "_" + "image.png" |
There was a problem hiding this comment.
SaveImageToTempFile writes to a deterministic path (<tmp>/<prefix>_image.png). This causes two problems: (1) later paste operations overwrite earlier queued attachments, and (2) predictable temp paths are unsafe (symlink/clobber risk). Please switch to os.CreateTemp with a unique filename.
| } | ||
|
|
||
| func (a *App) checkModelImageSupport() bool { | ||
| if a.currentModelCapabilities.checked { |
There was a problem hiding this comment.
Model image capability is cached once (checked=true) but never invalidated when provider/model changes. After switching models, canSendImageInput() can return stale results and incorrectly block or allow image sending. Consider resetting this cache whenever current provider/model changes.
| return detected | ||
| } | ||
|
|
||
| data, err := os.ReadFile(path) |
There was a problem hiding this comment.
DetectImageMimeType falls back to os.ReadFile(path), which loads the entire file into memory to inspect magic bytes. In picker flows this can be triggered before size checks and may cause large memory spikes/UI stalls. Prefer reading a small header buffer (e.g., 512 bytes).
| @@ -97,7 +97,7 @@ func (k keyMap) ShortHelp() []key.Binding { | |||
| func (k keyMap) FullHelp() [][]key.Binding { | |||
There was a problem hiding this comment.
Ctrl+V (PasteImage) is added to key bindings, but FullHelp() does not include it, so users won’t discover this capability from the built-in help panel.
Codecov Report❌ Patch coverage is 📢 Thoughts on this report? Let us know! |
|
/code 补全测试覆盖率至百分之八十以上修复review提到的问题 |
处理结果已按你的要求完成“修复 review 问题 + 补测试”。本次已推送到当前 PR 分支 已修复的 review 问题
测试补充新增/增强测试:
验证结果
说明: 未做项
|
- fix image attachment send path metadata composition and cache invalidation - secure clipboard temp file creation with unique names - optimize image mime detection using header reads - expose Ctrl+V in full help and add targeted tests Generated with [codeagent](https://github.com/qbox/codeagent) Co-authored-by: creatang <165447160+creatang@users.noreply.github.com>
|
/code |
处理结果已按你的要求补齐覆盖率相关测试,并已推送到当前 PR 分支: 提交: 本次主要改动
覆盖率结果(关键函数)
验证
未做项
|
Generated with [codeagent](https://github.com/qbox/codeagent) Co-authored-by: creatang <165447160+creatang@users.noreply.github.com>
…er-fix test(tui): improve multimodal and session-switch coverage
|
@xgopilot 当前TUI负责图片上传组装等是否合适 |
结论不太合适作为长期架构。当前实现能工作,但把“发送前多模态消息组装”放在 TUI,已经开始侵入 runtime/provider 职责边界。 依据(对应当前代码)
建议分层
额外风险点当前拼接内容包含绝对路径( |
@xgopilot 我还注意到,TUI还负责图片的副本保存,如果这部分日后要修改,应该放在哪里呢? |
结论你提到的“图片副本保存”长期不应继续放在 依据(当前实现位置)
建议分层(后续改这块时放哪里)
最小迁移路径
本次未做
|
背景
#293 本 PR 聚焦两个阶段能力:
本次改动
Phase 8: 多模态接入
Phase 9: 会话切换
/session打开会话列表并切换会话。说明
Ctrl+N新建会话;Ctrl+L打开会话列表可在后续补充。验证
go test ./internal/tui/core/app ./internal/tui/core/utils ./internal/tui/statego test ./...本地 Windows 环境下
internal/gateway/handlers有与本 PR 无关的既有路径安全测试失败,其余相关模块通过。影响范围